package vip.meeet.thread.lock;

/**
 * https://mp.weixin.qq.com/s?__biz=MzIyNDU2ODA4OQ==&mid=2247484266&idx=1&sn=fa4df50ba15258825de2158716e2d975&chksm=e80db51cdf7a3c0a62a6ceda801dd14abde253165c33e01eab6c472404a59cc6a19a39635924&scene=21#wechat_redirect
 */
public class NotifyStart {

    public synchronized void testWait(){
        System.out.println(Thread.currentThread().getName() +" Start-----");
        try {
            wait(0);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() +" End-------");
    }

    public static void main(String[] args) throws InterruptedException {
        final NotifyStart test = new NotifyStart();
        for(int i=0;i<5;i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    test.testWait();
                }
            }).start();
        }

        synchronized (test) {
            test.notify();
        }
        Thread.sleep(3000);
        System.out.println("-----------分割线-------------");

        synchronized (test) {
            test.notifyAll();
        }
    }
}
